package me.ivps.android.testdemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;

public class ReceiverActivity extends Activity {
    
    private static final String EXTRA_SENDER_MESSAGE_TEXT = "me.ivps.android.testdemo.extra.sender.message.text";
    
    public static Intent newIntent(SenderActivity context, CharSequence msg) {
        return new Intent(context, ReceiverActivity.class).putExtra(
                EXTRA_SENDER_MESSAGE_TEXT, msg);
    }
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.activity_receiver);
        
        final CharSequence msg = getIntent().getCharSequenceExtra(
                EXTRA_SENDER_MESSAGE_TEXT);
        if (!TextUtils.isEmpty(msg)) {
            ((TextView) findViewById(R.id.tv_received_text)).setText(msg);
        }
    }
    
}
